﻿// Author:				    Joe Audette
// Created:			        2010-05-11
// Last Modified:		    2010-08-10
// 
// The use and distribution terms for this software are covered by the 
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by 
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.

using System;
using System.Collections;
using System.Globalization;
using System.Web.UI.WebControls;
using mojoPortal.Web.Controls.google;
using mojoPortal.Web.Framework;

namespace ud_Search
{
    /// <summary>
    /// encapsulates the feature instance configuration loaded from module settings into a more friendly object
    /// </summary>
    public class SearchConfiguration
    {
        public SearchConfiguration()
        { }

        public SearchConfiguration(Hashtable settings)
        {
            LoadSettings(settings);
        }

        private void LoadSettings(Hashtable settings)
        {
            if (settings == null) { throw new ArgumentException("must pass in a hashtable of settings"); }

            if (settings.Contains("CustomCssClassSetting"))
            {
                customCssClass = settings["CustomCssClassSetting"].ToString();
            }
            useLeftSeparator = WebUtils.ParseBoolFromHashtable(settings, "UseLeftSeparatorSetting", useLeftSeparator);
            linkOnly = WebUtils.ParseBoolFromHashtable(settings, "LinkOnlySetting", linkOnly);
            useHeading = WebUtils.ParseBoolFromHashtable(settings, "UseHeadingSetting", useHeading);
            useWatermark = WebUtils.ParseBoolFromHashtable(settings, "UseWatermarkSetting", useWatermark);
            if (settings.Contains("ImageUrlSetting"))
            {
                imageUrl = settings["ImageUrlSetting"].ToString();
            }
            if (settings.Contains("ButtonCssClassSetting"))
            {
                buttonCssClass = settings["ButtonCssClassSetting"].ToString();
            }
            if (settings.Contains("TextBoxCssClassSetting"))
            {
                textBoxCssClass = settings["TextBoxCssClassSetting"].ToString();
            }
            renderAsListItem = WebUtils.ParseBoolFromHashtable(settings, "RenderAsListItemSetting", renderAsListItem);
            if (settings.Contains("ListItemCssSetting"))
            {
                listItemCSS = settings["ListItemCssSetting"].ToString();
            }
            if (settings.Contains("OverrideWatermarkSetting"))
            {
                overrideWatermark = settings["OverrideWatermarkSetting"].ToString();
            }

            if (settings.Contains("HeaderTextSetting"))
            {
                headerText = settings["HeaderTextSetting"].ToString();
            }

            if (settings.Contains("FooterTextSetting"))
            {
                footerText = settings["FooterTextSetting"].ToString();
            }
            if (settings.Contains("ButtonTextSetting"))
            {
                buttonText = settings["ButtonTextSetting"].ToString();
            }
        }

        private string customCssClass = string.Empty;
        public string CustomCssClass
        {
            get { return customCssClass; }
        }

        private bool useLeftSeparator = false;
        public bool UseLeftSeparator
        {
            get { return useLeftSeparator; }
            set { useLeftSeparator = value; }
        }

        private bool linkOnly = true;
        public bool LinkOnly
        {
            get { return linkOnly; }
            set { linkOnly = value; }
        }

        private bool useHeading = true;
        public bool UseHeading
        {
            get { return useHeading; }
            set { useHeading = value; }
        }

        private bool useWatermark = true;
        public bool UseWatermark
        {
            get { return useWatermark; }
            set { useWatermark = value; }
        }

        private string imageUrl = string.Empty;
        public string ImageUrl
        {
            get { return imageUrl; }
            set { imageUrl = value; }
        }

        private string buttonCssClass = string.Empty;
        public string ButtonCssClass
        {
            get { return buttonCssClass; }
            set { buttonCssClass = value; }
        }

        private string textBoxCssClass = string.Empty;
        public string TextBoxCssClass
        {
            get { return textBoxCssClass; }
            set { textBoxCssClass = value; }
        }

        private bool renderAsListItem = false;
        public bool RenderAsListItem
        {
            get { return renderAsListItem; }
            set { renderAsListItem = value; }
        }

        private string listItemCSS = "topnavitem";
        public string ListItemCss
        {
            get { return listItemCSS; }
            set { listItemCSS = value; }
        }

        private string overrideWatermark = string.Empty;
        public string OverrideWatermark
        {
            get { return overrideWatermark; }
            set { overrideWatermark = value; }
        }
        private string headerText = string.Empty;
        public string HeaderText
        {
            get { return headerText; }
            set { headerText = value; }
        }

        private string footerText = string.Empty;
        public string FooterText
        {
            get { return footerText; }
            set { footerText = value; }
        }
        private string buttonText = string.Empty;
        public string ButtonText
        {
            get { return buttonText; }
            set { buttonText = value; }
        }
    }
}